package com.wuyoucar.service.impl;

import com.wuyoucar.common.ResultBean;
import com.wuyoucar.entity.TOrder;
import com.wuyoucar.mapper.OrderMapper;
import com.wuyoucar.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public List<TOrder> getAllOrderByUserid(int userid) {
        List<TOrder> allOrderByUserid = orderMapper.getAllOrderByUserid(userid);
        return allOrderByUserid;
    }

    @Override
    public ResultBean addOrder(TOrder order) {
        int n = orderMapper.addOrder(order);
        if (n > 0){
            return new ResultBean(200,"下单成功");
        }else{
            return new ResultBean(404,"抱歉下单失败,请重新下单");
        }

    }
}
